package com.manage.competition.util;

import org.apache.shiro.crypto.hash.Sha256Hash;
import org.apache.shiro.crypto.hash.SimpleHash;
import org.apache.shiro.util.ByteSource;

/**
 * Create with IDEA
 *
 * @Author: gitee.com/KamisamaXX
 * @Date: Create in 22:13 2019/4/5
 * @Description:
 */
public class HashPasswordUtil {

    static private final String HASHALGORITHNAME = Sha256Hash.ALGORITHM_NAME;

    //加密次数
    static private final int HASHITERATIONS = 1024;

    static public String hashpassword(String username,String password){
        ByteSource credentialsSalt = ByteSource.Util.bytes(username);
        return new SimpleHash(HASHALGORITHNAME, password, credentialsSalt, HASHITERATIONS).toHex();
    }
}
